package org.catspaw.cherubim.text.stroke;

import java.io.Serializable;
import java.util.Comparator;

public class DefaultStrokeDictionaryEntry implements StrokeDictionary.Entry,
		Serializable, Cloneable, Comparable<DefaultStrokeDictionaryEntry> {

	private static final long										serialVersionUID	= 776204782564848593L;
	public static final Comparator<DefaultStrokeDictionaryEntry>	COMPARATOR			= new Comparator<DefaultStrokeDictionaryEntry>() {

																							public int compare(
																									DefaultStrokeDictionaryEntry o1,
																									DefaultStrokeDictionaryEntry o2) {
																								return o1
																										.compareTo(o2);
																							}
																						};
	private char													character;
	private int														codePoint;
	private int														stroke;

	public DefaultStrokeDictionaryEntry(char character, int codePoint,
			int stroke) {
		this.character = character;
		this.codePoint = codePoint;
		this.stroke = stroke;
	}

	public char getChar() {
		return character;
	}

	public int getCodePoint() {
		return codePoint;
	}

	public int getStroke() {
		return stroke;
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		return new DefaultStrokeDictionaryEntry(character, codePoint, stroke);
	}

	public int compareTo(DefaultStrokeDictionaryEntry o) {
		return this.codePoint - o.codePoint;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codePoint;
		result = prime * result + stroke;
		result = prime * result + character;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		DefaultStrokeDictionaryEntry other = (DefaultStrokeDictionaryEntry) obj;
		if (codePoint != other.codePoint) {
			return false;
		}
		if (stroke != other.stroke) {
			return false;
		}
		if (character != other.character) {
			return false;
		}
		return true;
	}
}
